#计算4个小数的平均值
# a = input("请输入第一个数字:")
# b = input("请输入第二个数字:")
# c = input("请输入第三个数字:")
# d = input("请输入第四个数字:")
# a = float(a)
# b = float(b)
# c = float(c)
# d = float(d)
# ave = (a + b + c + d) / 4
# print(f'平均值为:{ave}')
# choose = input('请选择选项（1表示好好学习/2表示摆烂）:')
# if choose == '1':
#     print('拿到一个好Offer~')
# elif choose == '2':
#     print('混吃等死~')
# else:
#     print('输入非法，请重新输入')

#判断闰年
# year = int(input("请输入年份:"))
# if (year % 100 != 0 and year % 4 == 0) or year % 400 == 0:
#     print("是闰年~")
# else:
#     print("不是闰年")

#求5！

# i = 1
# sum = 1
# while i <= 5:
#     sum *= i
#     i += 1
# print(f'5! = { sum }')

#求 1! + 2! + 3! + 4! + 5!

# i = 1
# sum = 0
# while i <= 5:
#     j = 1
#     jc = 1
#     while j <= i:
#         jc *= j
#         j += 1
#     sum += jc
#     i += 1
# print(f'1! + 2! + 3! + 4! + 5! = { sum }')

# #求1到100的和
# theSum = 0
# for i in range(1, 101):
#     theSum += i
# print(f'1到100的和为:{theSum}')

#加和函数

# def the_sum(start, end):
#     ret_sum = 0
#     for i in range(start, end + 1):
#         ret_sum += i
#     return ret_sum
# print(f'1-100和为:{the_sum(1,100)}')

#获取一个点的坐标
# def gain_point():
#     x = 10
#     y = 50
#     return x, y
#
# a, b = gain_point()
# print(f'a = {a}, b = {b}')

#函数内对全局变量的修改
# x = 10
# def diff():
#     global x
#     x = 50
# diff()
# print(x)

#切片操作
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# print(a[1])
# print(a[:])
# print(a[0:3])
# print(a[::2]) #设置取元素的步长为2
# print(a[1:-1])

#列表的遍历
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# for elem in a:
#     print(elem)
# for i in range(0, len(a)):
#     print(a[i] + 10)

# #插入
# #1.使用append方法在末尾插入
# a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# a.append('hello')
# print(a)
# #2.使用insert在任意位置插入
# a.insert(1, '插入到下标为1的位置')
# print(a)
# #3.即使越界，也会放到列表的极端位置
# a.insert(100, '插入到列表的边界')
# print(a)

#删除的三种方式

# a = [1, 2, 3, 4, 5]
# s = ['aa', 'bb', 'cc']
# #默认删最后一个
# a.pop()
# #删除指定位置元素
# a.pop(3)
# #删除对应元素
# s.remove('bb')
# print(a)
# print(s)

# #列表拼接
# a = [1, 2, 3, 4, 5]
# s = ['aa', 'bb', 'cc']
# #1.拼接创建新的列表
# add = a + s
# print(add)
# #2.拼接修改原列表
# a.extend(s)
# print(a)
# print(s)
# #3.拼接修改原列表的另一种方式
# a += s
# print(a)

#元组
#使用和列表几乎一样，只是元组创建好以后就不可以修改，而列表创建好以后可以修改
# a = (1, 2, 3, 4, 5)
# for elem in a:
#     print(elem)

#字典 (优点类似于map，key和value组成)
a = {'id': 1,
     'name': 'jaychou',#最后这个逗号可有可无
     100: 'hello'
}
# #访问(很高效，底层是哈希表，比列表查询操作要高效的多)
# print(a['id'])
# print(a['name'])
# print(a[100])
# #插入操作
# a['key'] = 'world'
# print(a)
# #修改操作
# a['id'] = 2
# print(a)
# #删除，根据key来删除
# a.pop('key')
# print(a)
# #字典的遍历
# for i in a:
#     print(i, a[i])
# #

student = {
    'key' : 5
}
students = [student]

def show():
    for stu in students:
        print('hello')
        a = 4
    print(stu)
    b = a




